package com.mixsmart.core.dao.impl;

import java.util.HashMap;

import org.springframework.stereotype.Repository;

import com.mixsmart.core.dao.IExecuteDao;
import com.mixsmart.utils.ArrayUtils;

/**
 * 执行DAO实现类
 * @version 1.0
 * @since JDK1.6以上
 * @author lmq
 * <br />
 * 2016年7月23日
 */
@Repository
public class ExecuteDaoImpl extends HibernateDao implements IExecuteDao {

	@Override
	public boolean execute(String sql) {
		return this.execute(sql, null);
	}

	@Override
	public boolean executeHQL(String hql) {
		return this.executeHQL(hql, null);
	}

	@Override
	public boolean execute(String sql, HashMap<String, Object> params) {
		return super.executeSQL(sql, params, false);
	}

	@Override
	public boolean executeHQL(String hql, HashMap<String, Object> params) {
		return super.executeHQL(hql, params, false);
	}

	@Override
	public boolean executeByFilter(String sql, HashMap<String, Object> params) {
		return super.executeSQL(sql, params, true);
	}

	@Override
	public boolean executeHQLByFilter(String hql, HashMap<String, Object> params) {
		return super.executeHQL(hql, params, true);
	}

	@Override
	public boolean executes(String[] sqls) {
		if(ArrayUtils.isEmpty(sqls)) {
			return false;
		}
		for(String sql : sqls) {
			this.execute(sql);
		}
		return true;
	}

	@Override
	public boolean executesHQL(String[] hqls) {
		if(ArrayUtils.isEmpty(hqls)) {
			return false;
		}
		for(String hql : hqls) {
			this.executeHQL(hql);
		}
		return true;
	}

	@Override
	public boolean executes(String[] sqls, HashMap<String, Object> params) {
		if(ArrayUtils.isEmpty(sqls)) {
			return false;
		}
		for(String sql : sqls) {
			this.execute(sql, params);
		}
		return true;
	}

	@Override
	public boolean executesHQL(String[] hqls, HashMap<String, Object> params) {
		if(ArrayUtils.isEmpty(hqls)) {
			return false;
		}
		for(String hql : hqls) {
			this.executeHQL(hql, params);
		}
		return true;
	}

	@Override
	public boolean executesByFilter(String[] sqls, HashMap<String, Object> params) {
		if(ArrayUtils.isEmpty(sqls)) {
			return false;
		}
		for(String sql : sqls) {
			super.executeSQL(sql, params, true);
		}
		return true;
	}

	@Override
	public boolean executesHQLByFilter(String[] hqls, HashMap<String, Object> params) {
		if(ArrayUtils.isEmpty(hqls)) {
			return false;
		}
		for(String hql : hqls) {
			super.executeHQL(hql, params, true);
		}
		return true;
	}

	
}
